package net.sk.china.city.domain.dto.activity;

import net.sk.china.city.domain.ArActivity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

import static net.sk.china.city.utils.JsonStrCovertUtil.objToStr;

@Data
public class ActivityUpdateDTO {
    /** 主键 */
    @ApiModelProperty(value = "主键")
    private Long pkId;

    @ApiModelProperty(value = "活动名")
    private String activityName;

    @ApiModelProperty(value = "封面URL")
    private String cover;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "活动开始时间")
    private LocalDateTime startDatetime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "活动结束时间")
    private LocalDateTime endDatetime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "报名截止时间")
    private LocalDateTime signEndDatetime;

    @ApiModelProperty(value = "总人数限制")
    private Long maxCount;

    @ApiModelProperty(value = "条件说明")
    private String conditionRequire;

    @ApiModelProperty(value = "活动介绍")
    private String description;

    @ApiModelProperty(value = "活动地点")
    private String address;

    @ApiModelProperty(value = "活动状态：0:报名中，1:已截止报名，2:已结束")
    private Long status;

    @ApiModelProperty(value = "岗位，对象数组")
    private List<Job> job;

    @ApiModelProperty(value = "场次，对象数组")
    private List<Session> session;

    @ApiModelProperty(value = "特点，数组")
    private List<Feature> feature;

    @ApiModelProperty(value = "福利，数组")
    private List<Welfare> welfare;

    @ApiModelProperty(value = "主办方，数组")
    private List<Organizer> organizer;

    @ApiModelProperty(value = "工时（积分）")
    private BigDecimal workHour;

    @ApiModelProperty(value = "隔离字段")
    private String platformId;

    public ArActivity toActivity() {
        ArActivity arActivity = new ArActivity();
        arActivity.setPkId(pkId);
        arActivity.setActivityName(activityName);
        arActivity.setCover(cover);
        arActivity.setStartDatetime(startDatetime);
        arActivity.setEndDatetime(endDatetime);
        arActivity.setSignEndDatetime(signEndDatetime);
        arActivity.setMaxCount(maxCount);
        arActivity.setConditionRequire(conditionRequire);
        arActivity.setDescription(description);
        arActivity.setAddress(address);
        arActivity.setStatus(status);
        String jobJsonStr = objToStr(job);
        arActivity.setJob(jobJsonStr);
        String sessionJsonStr = objToStr(session);
        arActivity.setSession(sessionJsonStr);
        String featureJsonStr = objToStr(feature);
        arActivity.setFeature(featureJsonStr);
        String welfareJsonStr = objToStr(welfare);
        arActivity.setWelfare(welfareJsonStr);
        String organizerJsonStr = objToStr(organizer);
        arActivity.setOrganizer(organizerJsonStr);
        arActivity.setWorkHour(workHour);
        return arActivity;
    }
}
